home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / programming / e / powerd0.06 / modules / dos / dosasl.m < prev    next >
Text File  |  1999-11-30  |  4KB  |  124 lines

  1. MODULE    'exec/libraries',
  2.             'exec/lists',
  3.             'dos/dos'
  4.  
  5. /***********************************************************************
  6. ************************ PATTERN MATCHING ******************************
  7. ************************************************************************
  8.  
  9. * structure expected by MatchFirst, MatchNext.
  10. * Allocate this structure and initialize it as follows:
  11. *
  12. * Set ap_BreakBits to the signal bits (CDEF) that you want to take a
  13. * break on, or NULL, if you don't want to convenience the user.
  14. *
  15. * If you want to have the FULL PATH NAME of the files you found,
  16. * allocate a buffer at the END of this structure, and put the size of
  17. * it into ap_Strlen.  If you don't want the full path name, make sure
  18. * you set ap_Strlen to zero.  In this case, the name of the file, and stats
  19. * are available in the ap_Info, as per usual.
  20. *
  21. * Then call MatchFirst() and then afterwards, MatchNext() with this structure.
  22. * You should check the return value each time (see below) and take the
  23. * appropriate action, ultimately calling MatchEnd() when there are
  24. * no more files and you are done.  You can tell when you are done by
  25. * checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.
  26. *
  27. */
  28.  
  29. OBJECT AnchorPath
  30.     Base|First:PTR TO AChain,        /* pointer to first anchor */
  31.     Last|Current:PTR TO AChain,    /* pointer to last anchor */
  32.     BreakBits:LONG,                    /* Bits we want to break on */
  33.     FoundBreak:LONG,                    /* Bits we broke on. Also returns ERROR_BREAK */
  34.     Flags|Length:BYTE,                /* New use for extra word. */
  35.     Reserved:BYTE,
  36.     Strlen:WORD,                        /* This is what ap_Length used to be */
  37.     Info:FileInfoBlock,
  38.     Buf[1]:UBYTE                        /* Buffer for path name, allocated by user */
  39.     /* FIX! */
  40.  
  41.  
  42. #define APB_DOWILD    0    /* User option ALL */
  43. #define APF_DOWILD    1
  44.  
  45. #define APB_ITSWILD    1    /* Set by MatchFirst, used by MatchNext     */
  46. #define APF_ITSWILD    2    /* Application can test APB_ITSWILD, too */
  47.                 /* (means that there's a wildcard     */
  48.                 /* in the pattern after calling         */
  49.                 /* MatchFirst).                 */
  50.  
  51. #define    APB_DODIR    2    /* Bit is SET if a DIR node should be */
  52. #define APF_DODIR    4    /* entered. Application can RESET this */
  53.                 /* bit after MatchFirst/MatchNext to AVOID */
  54.                 /* entering a dir. */
  55.  
  56. #define APB_DIDDIR    3    /* Bit is SET for an "expired" dir node. */
  57. #define APF_DIDDIR    8
  58.  
  59. #define APB_NOMEMERR    4    /* Set on memory error */
  60. #define APF_NOMEMERR    16
  61.  
  62. #define APB_DODOT    5    /* If set, allow conversion of '.' to */
  63. #define APF_DODOT    32    /* CurrentDir */
  64.  
  65. #define APB_DirChanged    6    /* ap_Current->an_Lock changed */
  66. #define APF_DirChanged    64    /* since last MatchNext call */
  67.  
  68. #define APB_FollowHLinks 7    /* follow hardlinks on DODIR - defaults   */
  69. #define APF_FollowHLinks 128    /* to not following hardlinks on a DODIR. */
  70.  
  71.  
  72. OBJECT AChain
  73.     Child:PTR TO AChain,
  74.     Parent:PTR TO AChain,
  75.     Lock:BPTR,
  76.     Info:FileInfoBlock,
  77.     Flags:UBYTE,
  78.     String[1]:UBYTE    /* FIX!! */
  79.  
  80. #define    DDB_PatternBit        0
  81. #define    DDF_PatternBit        1
  82. #define    DDB_ExaminedBit    1
  83. #define    DDF_ExaminedBit    2
  84. #define    DDB_Completed        2
  85. #define    DDF_Completed        4
  86. #define    DDB_AllBit            3
  87. #define    DDF_AllBit            8
  88. #define    DDB_Single            4
  89. #define    DDF_Single            16
  90.  
  91. /*
  92.  * Constants used by wildcard routines, these are the pre-parsed tokens
  93.  * referred to by pattern match.  It is not necessary for you to do
  94.  * anything about these, MatchFirst() MatchNext() handle all these for you.
  95.  */
  96.  
  97. #define P_ANY            $80    /* Token for '*' or '#?  */
  98. #define P_SINGLE        $81    /* Token for '?' */
  99. #define P_ORSTART        $82    /* Token for '(' */
  100. #define P_ORNEXT        $83    /* Token for '|' */
  101. #define P_OREND        $84    /* Token for ')' */
  102. #define P_NOT            $85    /* Token for '~' */
  103. #define P_NOTEND        $86    /* Token for */
  104. #define P_NOTCLASS    $87    /* Token for '^' */
  105. #define P_CLASS        $88    /* Token for '[]' */
  106. #define P_REPBEG        $89    /* Token for '[' */
  107. #define P_REPEND        $8A    /* Token for ']' */
  108. #define P_STOP            $8B    /* token to force end of evaluation */
  109.  
  110. /* Values for an_Status, NOTE: These are the actual bit numbers */
  111.  
  112. #define COMPLEX_BIT    1    /* Parsing complex pattern */
  113. #define EXAMINE_BIT    2    /* Searching directory */
  114.  
  115. /*
  116.  * Returns from MatchFirst(), MatchNext()
  117.  * You can also get dos error returns, such as ERROR_NO_MORE_ENTRIES,
  118.  * these are in the dos.h file.
  119.  */
  120.  
  121. #define ERROR_BUFFER_OVERFLOW    303    /* User or internal buffer overflow */
  122. #define ERROR_BREAK                304    /* A break character was received */
  123. #define ERROR_NOT_EXECUTABLE    305    /* A file has E bit cleared */
  124.